package com.wudl.flink;


import org.apache.commons.lang3.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * TODO
 *
 * @author wudl
 * @version 1.0
 * @date 2021/3/15 11:41
 */
public class DateUtils {

    public static void main(String[] args) {

        Date d = new Date();
        String beginDate = "1609436744000";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 时间戳转换日期
        String sd = sdf.format(new Date(Long.parseLong(beginDate)));
        System.out.println(d.getTime());
        System.out.println(sd);

    }

    public static String dateFormat(String time) {
        //UTC是本地时间
        time = time.replace("Z", " UTC");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z");
        Date d = null;
        try {
            d = format.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = sf.format(d);
        System.out.println(sf.format(d));
        return sf.format(d);
    }

    public static String   getFormatDate(String time)
    {
        Date d = new Date();
//        String beginDate = "1609436744000";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 时间戳转换日期
        String sd = sdf.format(new Date(Long.parseLong(time)));
        System.out.println(sd);
        return  sd;
    }


}
